//
//  LLAssetsPickerAlbumsCell.m
//  LLCoreUserInterface
//
//  Created by my_liu on 2016/11/16.
//  Copyright © 2016年 my_liu. All rights reserved.
//

#import "LLAssetsPickerAlbumsCell.h"
#import "LLAssetsPickerConstans.h"

@interface LLAssetsPickerAlbumsCell ()
{
    UIView *_line;
}
@end

@implementation LLAssetsPickerAlbumsCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        _line = [[UIView alloc]initWithFrame:CGRectZero];
        _line.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:1];
        [self.contentView addSubview:_line];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    /*  系统样式，如果要完全自定义相册的Cell请进行继承，然后重新设置自己想要的样式 */
    self.imageView.frame = CGRectMake(8, 8, 49, 49);
    self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    self.textLabel.textColor = [UIColor colorWithRed:38.0/255.0 green:38.0/255.0 blue:38.0/255.0 alpha:1.0];
    self.textLabel.font = [UIFont systemFontOfSize:16];
    [self.textLabel sizeToFit];
    self.textLabel.frame = (CGRect){70,24,self.textLabel.frame.size.width,self.textLabel.frame.size.height};
    
    self.detailTextLabel.textColor = [UIColor colorWithRed:153.0/255.0 green:153.0/255.0 blue:153.0/255.0 alpha:1.0];
    self.detailTextLabel.font = [UIFont systemFontOfSize:16];
    [self.detailTextLabel sizeToFit];
    self.detailTextLabel.frame = (CGRect){self.textLabel.frame.origin.x+self.textLabel.frame.size.width+4.5,24,self.detailTextLabel.frame.size.width,self.detailTextLabel.frame.size.height};
    if (_isLast) {
        _line.frame = CGRectMake(0, self.bounds.size.height-0.5, self.bounds.size.width, 0.5f);
    } else {
        _line.frame = CGRectMake(70, self.bounds.size.height-0.5, self.bounds.size.width - 70, 0.5f);
    }
}

- (void)setAlbums:(LLAlbums *)aAlbums
{
    self.imageView.image = aAlbums.posterImage;
    self.textLabel.text = [NSString stringWithFormat:@"%@",aAlbums.name];
    self.detailTextLabel.text = [NSString stringWithFormat:@"(%ld)张",(long)aAlbums.totalCount];
    
    [self setNeedsLayout];
}

- (void)setIsLast:(BOOL)isLast
{
    _isLast = isLast;
    [self setNeedsLayout];
}

@end
